<template>
  <div class="login">
    <div class="login_body">
      <div class="login_title">
        行知管理系统
      </div>
      <el-form
        :model="account"
        :rules="rules"
        ref="account"
        label-width="100px"
        class="login-ruleForm"
      >
        <el-form-item label="用户名:" class="my_style" prop="userName">
          <el-input v-model="account.userName"></el-input>
        </el-form-item>
        <el-form-item label="密码:" class="my_style" prop="password">
          <el-input type="password" v-model="account.password"></el-input>
        </el-form-item>
        <el-row class="my_style">
          <el-button class="my_button" @click="submitForm('account')"
            >登陆</el-button
          >
        </el-row>
      </el-form>
    </div>
  </div>
</template>
<script>
// import {getRouterFormService} from "@/api/api"
export default {
  name: "login",
  data() {
    return {
      name: "Arya",
      account: {
        userName: "",
        password: ""
      },
      rules: {
        userName: [
          { required: true, message: "请输入用户名称", trigger: "blur" }
        ],
        password: [
          { required: true, message: "请输入用户密码", trigger: "blur" }
        ]
      }
    };
  },
  methods: {
    submitForm: function(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.$store.dispatch("login/login", this.account);
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm: function(formName) {
      this.$refs[formName].resetFields();
    },
    goIndex() {
      if (this.login) {
        this.$router.push("/index");
      }
    }
  },
  created() {},
  beforeCreate() {
    if (this.login) {
      this.$router.push("/index");
    }
  },
  computed: {
    login() {
      return this.$store.state.login.login;
    }
  }
};
</script>
<style lang="scss" scoped>
.login {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: url("../../assets/login_background.jpg") no-repeat;
  background-size: cover;
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  color: #96ada0;
  .login_body {
    width: 500px;
    height: 400px;
    background: linear-gradient(
      135deg,
      rgba(7, 113, 145, 0.8),
      rgba(39, 143, 10, 0.8)
    );
    border-radius: 20px;
    box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.3),
      0px 6px 10px 0px rgba(0, 0, 0, 0.1);
    .login_title {
      font-size: 40px;
      text-align: center;
      margin: 30px 30px 40px 30px;
      color: #b0cabb;
    }
  }
}
</style>
<style lang="scss">
.my_style {
  margin: 20px 60px 0px 60px;
  .el-form-item__label {
    color: #96ada0;
    font-family: "黑体";
    background: transparent;
    font-size: 18px;
    font-weight: bold;
  }
  .el-input {
    .el-input__inner {
      border-radius: 0px;
      min-width: 100px;
      background: transparent;
      border: 0px;
      border-bottom: 1px solid rgb(121, 102, 102);
      caret-color: white;
      color: #96ada0;
      font-size: 18px;
      font-weight: bold;
    }
  }

  .el-form-item__content {
    margin: 0px;
  }

  .my_button {
    background: hsla(170, 73%, 44%, 0.062);
    width: 100%;
    margin-top: 30px;
    color: wheat;
    font-size: 20px;
    border: 0px;
  }
  .my_button:hover {
    background: rgba(48, 146, 131, 0.3);
    color: wheat;
  }
  .my_button:focus {
    background: hsla(170, 73%, 44%, 0.2);
    color: wheat;
  }
}
</style>
